﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Update
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Thread.Sleep(1000);
            var zip = ConfigurationManager.AppSettings["UpdateFile"];
            if (string.IsNullOrWhiteSpace(zip) || !File.Exists(zip))
            {
                MessageBox.Show("找不到更新包文件,更新失败");
                return;
            }
            ZipFile.ExtractToDirectory(zip, Directory.GetCurrentDirectory());
            var target = ConfigurationManager.AppSettings["MainFile"];
            if (File.Exists(target))
            {
                Process.Start(target);
                Application.Exit();
            }
            else
            {
                MessageBox.Show("找不到启动文件,更新失败");
            }
        }
    }
}
